package com.web3.management.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;

/**
 * 账号实体类
 *
 * @author Web3 Management Team
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "accounts")
public class Account extends BaseEntity {

    /**
     * 账号名称
     */
    @Column(name = "name", length = 100, nullable = false)
    private String name;

    /**
     * Cookies信息
     */
    @Lob
    @Column(name = "cookies")
    private String cookies;

    /**
     * CSRF Token
     */
    @Column(name = "csrf_token")
    private String csrfToken;

    /**
     * 客户端访问Token哈希
     */
    @Column(name = "client_token_hash", length = 128)
    private String clientTokenHash;

    /**
     * 客户端访问Token签发时间
     */
    @Column(name = "client_token_issued_at")
    @Temporal(TemporalType.TIMESTAMP)
    private Date clientTokenIssuedAt;

    /**
     * 客户端访问Token到期时间
     */
    @Column(name = "client_token_expires_at")
    @Temporal(TemporalType.TIMESTAMP)
    private Date clientTokenExpiresAt;

    /**
     * 代理配置
     */
    @Lob
    @Column(name = "proxy_config")
    private String proxyConfig;

    /**
     * 账号状态：1启用，0禁用
     */
    @Column(name = "status", nullable = false)
    private Integer status = 1;

    /**
     * 备注信息
     */
    @Lob
    @Column(name = "remark")
    private String remark;

    /**
     * 是否需要重启客户端
     */
    @Column(name = "needs_restart")
    private Boolean needsRestart = false;

    /**
     * 最后重启时间
     */
    @Column(name = "last_restart_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastRestartTime;

    /**
     * 最后错误信息
     */
    @Lob
    @Column(name = "last_error_message")
    private String lastErrorMessage;

    /**
     * 最后错误时间
     */
    @Column(name = "last_error_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastErrorTime;
}
